/////////////////////////////////////////////////////////////////////////////
// Name:        SourceContainer.h
// Purpose:     
// Author:      Andrew (cod) Bulavinov
// Modified by: 
// Created:     06/01/2009 17:31:12
// RCS-ID:      
// Copyright:   
// Licence:     
/////////////////////////////////////////////////////////////////////////////

#ifndef _SOURCE_CONTAINER_H_
#define _SOURCE_CONTAINER_H_

#include <map>
#include <wx/wx.h>
#include <wx/dir.h>

typedef std::map<wxString, wxArrayString> DirMap;

static bool CheckFormat(const wxString & file, const wxArrayString filters);

// Media traverser
class MediaFinder : public wxDirTraverser
{
public:
    MediaFinder(wxString root, wxArrayString & filters) : _Root(root), _Filters(filters) {}

    virtual wxDirTraverseResult OnFile(const wxString& filename);
    virtual wxDirTraverseResult OnDir(const wxString& dirname);
private:
    wxArrayString _Filters;
    DirMap        _Entries;
    wxString      _CurrentEnty;
    wxString      _Root;
};

class Source {
public:
    Source() : _Processed(false) {}
    Source(wxString path) : Path(path), _Processed(false) {}
    ~Source() {}

    wxString      Path;
    wxArrayString Filters;
    bool          IsProcessed() const { return _Processed; }
    size_t        GetItemCount() const { return _ItemCount; }
    bool          Process();

private:
    bool          _Processed;
    wxArrayString _Items;
    size_t        _ItemCount;
};

class Sources {
public:
    Sources() {}
    ~Sources() {}
    bool Add(const wxString path, const wxArrayString filters);
    bool Update();

private:
    std::map<wxString, Source> _SrcList;
};

#endif //_SOURCE_CONTAINER_H_